import request from '@/utils/request'

export interface LoginParams {
  username: string
  password: string
}

export interface LoginResult {
  token: string
}

export const authApi = {
  // 密码登录
  passwordLogin: (data: LoginParams) => {
    return request.post<LoginResult>('/auth/login/password', data)
  },

  // 手机号登录
  phoneLogin: (data: { phone: string, password: string }) => {
    return request.post<LoginResult>('/auth/login/phone', data)
  },

  // 验证码登录
  smsLogin: (data: { phone: string, code: string }) => {
    return request.post<LoginResult>('/auth/login/sms', data)
  },

  // 发送验证码
  sendSms: (data: { phone: string, type: string }) => {
    return request.post('/auth/sms/send', data)
  },

  // 注册
  register: (data: { phone: string, password: string, code: string }) => {
    return request.post('/auth/register', data)
  },
  
  // 重置密码
  resetPassword: (data: { phone: string, sms: string, newPassword: string }) => {
    return request.post('/auth/reset-password', data)
  },

  // 退出登录
  logout: () => {
    return request.post('/auth/logout')
  }
}



